﻿using Prism.Commands;
using Prism.Mvvm;
using System.Windows;
using Hl.Core.Helper;
using XmlMod.Models;
using Hl.Core.Helper.Log.Serilog;

namespace XmlMod.ViewModels
{
    public class XmlMainViewModel : BindableBase
    {
        public string Title { get; set; } = "XML 测试";

        public DelegateCommand XmlTestCommand { get; set; }
        public XmlMainViewModel()
        {
            XmlTestCommand = new DelegateCommand(OnXmlTest);
            NLogHelper.Info("启动");

            SerilogLoggerFactory.FileLogManager().Information("Addition of {@message} is starting!", "XmlMain");
        }

        private void OnXmlTest()
        {
            NLogHelper.Info("Button Click");

            var htFirePointData = new HtFirePointData();
            var xmlString = string.Empty;
            xmlString = XmlHelper.SerializeObjectToXml<HtFirePointData>(htFirePointData);

            var obj = XmlHelper.DeserializeXmlToObject<HtFirePointData>(xmlString);

            MessageBox.Show(xmlString);
        }
    }
}
